const appConfig = require('./../../../config/router/config')
const axios = require('axios')
const qs = require('qs')

const DevRequest = {
    workerPerson(req, res) {
        const url = `${appConfig.baseURL}/worker/person`
        // appConfig.headers.avoidAuthorization = false
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    theme(req, res) {
        const url = `${appConfig.baseURL}/theme`
        // appConfig.headers.avoidAuthorization = false
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    shareConfig(req, res) {
        const url = `${appConfig.baseURL}/wechat/webEmpower/jsConfig`
        // appConfig.headers.avoidAuthorization = false
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    describe(req, res) {
        const url = `${appConfig.baseURL}/company/describe`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    job(req, res) {
        const url = `${appConfig.baseURL}/worker/jobList`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    industry(req, res) {
        const url = `${appConfig.baseURL}/industry`
        axios({
            method: 'get',
            url,
            data: req.query,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    area(req, res) {
        const url = `${appConfig.baseURL}/area`
        axios({
            method: 'get',
            url,
            data: req.query,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    star(req, res) {
        const url = `${appConfig.baseURL}/worker/job/star`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    jobDetail(req, res) {
        const url = `${appConfig.baseURL}/worker/job/show`
        axios({
            methods: 'get',
            params: req.query,
            headers: appConfig.headers,
            url: url
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    company(req, res) {
        const url = `${appConfig.baseURL}/worker/company`
        axios({
            method: 'get',
            url,
            params: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: err })
        })
    },
    resumeShow(req, res) {
        const url = `${appConfig.baseURL}/worker/show`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    showDemand(req, res) {
        const url = `${appConfig.baseURL}/worker/showDemand`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    wokerMe(req, res) {
        const url = `${appConfig.baseURL}/worker/me`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    companyMe(req, res) {
        const url = `${appConfig.baseURL}/company/me`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    workerStarred(req, res) {
        const url = `${appConfig.baseURL}/worker/job/starred`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    workerApplied(req, res) {
        const url = `${appConfig.baseURL}/worker/job/applied`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    positionList(req, res) {
        const url = `${appConfig.baseURL}/position`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    editDemand(req, res) {
        const url = `${appConfig.baseURL}/worker/demand`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    editResume(req, res) {
        const url = `${appConfig.baseURL}/worker/resume`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    license(req, res) {
        const url = `${appConfig.baseURL}/company/company/license`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    showLicense(req, res) {
        const url = `${appConfig.baseURL}/company/company/showLicense`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    companyResume(req, res) {
        const url = `${appConfig.baseURL}/company/resume`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    companyResumeItem(req, res) {
        const url = `${appConfig.baseURL}/company/resume/item`
        axios({
            method: 'get',
            url,
            params: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    refuseResume(req, res) {
        const url = `${appConfig.baseURL}/company/resume/refuse`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    callResume(req, res) {
        const url = `${appConfig.baseURL}/company/resume/call`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    companyShow(req, res) {
        const url = `${appConfig.baseURL}/company/company/show`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    companyJobList(req, res) {
        const url = `${appConfig.baseURL}/company/job/list`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    editJob(req, res) {
        const url = `${appConfig.baseURL}/company/job/describe`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    companyjobDetail(req, res) {
        const url = `${appConfig.baseURL}/company/job/show`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    jobOffline(req, res) {
        const url = `${appConfig.baseURL}/company/job/offline`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    tag(req, res) {
        const url = `${appConfig.baseURL}/tag`
        axios({
            method: 'get',
            url,
            data: req.query,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    jobApply(req, res) {
        const url = `${appConfig.baseURL}/worker/job/apply`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    myCompany(req, res) {
        const url = `${appConfig.baseURL}/company/company/list`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    workerWallet(req, res) {
        const url = `${appConfig.baseURL}/worker/wallet`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    workerWalletLog(req, res) {
        const url = `${appConfig.baseURL}/worker/wallet/log`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    buyResume(req, res) {
        const url = `${appConfig.baseURL}/company/resume/buy`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    complaint(req, res) {
        const url = `${appConfig.baseURL}/worker/job/complaint`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    resumeOrder(req, res) {
        const url = `${appConfig.baseURL}/company/resume/order`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    walletLog(req, res) {
        const url = `${appConfig.baseURL}/company/wallet/log`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    getSaas(req, res) {
        const url = `${appConfig.baseURL}/index/resolveSaas`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },

    //企业端充值
    recharge(req, res) {
        let url = req.originalUrl
        axios.post(url, {}, {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
        // axios({
        //     method: 'get',
        //     url,
        //     headers: appConfig.headers
        // }).then((response) => {
        //     res.json(response.data)
        // }).catch(err => {
        //     res.json({ code: '-1', message: '请求错误' })
        // })
    },

    //formId获取
    // collectionFormid(req, res) {
    //     let url = 'wechat/collection-form-id/' + json
    //     const url = `${appConfig.baseURL}/worker/show`
    //     axios({
    //         method: 'post',
    //         url,
    //         data: req.body,
    //         headers: appConfig.headers
    //     }).then((response) => {
    //         res.json(response.data)
    //     }).catch(err => {
    //         res.json({ code: '-1', message: '请求错误' })
    //     })
    //     return new Promise((resolve, reject) => {
    //         taroRequest.request({
    //             url: url,
    //             method: 'GET',
    //         }).then(res => {
    //             resolve(res)
    //         }).catch(err => {
    //             reject(err)
    //         })
    //     })
    // },
    applyWithdraw(req, res) {
        const url = `${appConfig.baseURL}/worker/apply-withdraw`
        axios({
            method: 'get',
            url,
            data: req.query,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },

    //新建/编辑简历升级版
    resumev2(req, res) {
        const url = `${appConfig.baseURL}/worker/resumev2`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },

    //企业海报
    CompanyPoster(req, res) {
        const url = `${appConfig.baseURL}/poster/companyPoster`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },

    //职位海报
    JobPoster(req, res) {
        const url = `${appConfig.baseURL}/poster/JobPoster`
        // axios.post(url, qs.stringify(req.body), {
        //     headers: appConfig.headers
        // }).then((response) => {
        //     res.json(response.data)
        // }).catch(err => {
        //     res.json({ code: '-1', message: '请求错误' })
        // })
        axios({
            method: 'get',
            url,
            params: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: err })
        })

    },

    //协议信息
    protocol(req, res) {
        const url = `${appConfig.baseURL}/worker/protocol`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },

    resumePoolCategory(req, res) {
        const url = `${appConfig.baseURL}/company/job/resumePoolCategory`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },

    resumePool(req, res) {
        const url = `${appConfig.baseURL}/company/job/resumePool`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },

    //phoneLogin.js
    //手机号登陆
    phoneLogin(req, res) {
        const url = `${appConfig.baseURL}/login`
        axios({
            method: 'post',
            url,
            params: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    //微信授权
    userInfo(req, res) {
        const url = `${appConfig.baseURL}/login/wechatMPAuthorize`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },

    topList(req, res) {
        const url = `${appConfig.baseURL}/company/job/topList`
        axios({
            method: 'post',
            url,
            data: req.body,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },

    buyTopList(req, res) {
        const url = `${appConfig.baseURL}/company/job/buyTopList`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },

    //图片上传
    ossSign(req, res) {
        const url = `${appConfig.baseURL}/oss/sign`
        axios({
            method: 'get',
            url,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },

    //获取验证码
    verifyPhone(req, res) {
        const url = `${appConfig.baseURL}/wap/user/verifyPhone`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    //套餐信息
    memberList(req, res) {
        const url = `${appConfig.baseURL}/company/member/memberList`
        axios({
            method: 'get',
            url,
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    //购买会员
    buyMember(req, res) {
        const url = `${appConfig.baseURL}/company/member/buyMember`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },

    //购买会员加量包
    buyMemberMenu(req, res) {
        const url = `${appConfig.baseURL}/company/member/buyMemberMenu`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },

    //首页自定义转发卡片
    indexTranmistPoster(req, res) {
        const url = `${appConfig.baseURL}/poster/indexTranmistPoster`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },

    companyTranmistPoster(req, res) {
        const url = `${appConfig.baseURL}/poster/companyTranmistPoster`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },

    jobTranmistPoster(req, res) {
        const url = `${appConfig.baseURL}/poster/jobTranmistPoster`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },

    personInfo(req, res) {
        const url = `${appConfig.baseURL}/worker/personInfo`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
    workerStatus(req, res) {
        const url = `${appConfig.baseURL}/worker/workerStatus`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },

    topiceEntrance(req, res) {
        const url = `${appConfig.baseURL}/worker/topiceEntrance`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },

    customerConfig(req, res) {
        const url = `${appConfig.baseURL}/worker/customerConfig`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },

    redBag(req, res) {
        const url = `${appConfig.baseURL}/worker/redBag`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },

    getResumeRedBag(req, res) {
        const url = `${appConfig.baseURL}/worker/getResumeRedBag`
        axios.post(url, qs.stringify(req.body), {
            headers: appConfig.headers
        }).then((response) => {
            res.json(response.data)
        }).catch(err => {
            res.json({ code: '-1', message: '请求错误' })
        })
    },
}

module.exports = DevRequest;